package com.rhok.wthru_client.servermsgs;

import org.apache.http.message.BasicNameValuePair;

import android.content.Context;

import com.rhok.wthru_client.BasicContactInfo;
import com.rhok.wthru_client.GlobalConfiguration;

public class ServerMessageRegister extends ServerMessage {
	
	private BasicContactInfo m_selfInfo;
	private String m_gcmId;

	public void setGCMId(String gcmId) {
		m_gcmId = gcmId;
	}

	public ServerMessageRegister(Context context) {
		super(context);
		readInfo();
	}

	@Override
	protected String getRequestPath() {
		return "initial_registration";
	}
	
	private void readInfo() {
		
		GlobalConfiguration globalConf = GlobalConfiguration.getInstance(m_context);
		
		String name = globalConf.getString(GlobalConfiguration.CONF_KEY_NAME);
		String phone = globalConf.getString(GlobalConfiguration.CONF_KEY_PHONE);
		
		m_selfInfo = new BasicContactInfo(name, phone);
	}

	@Override
	public String send() {
		m_requestValues.add(new BasicNameValuePair("self", m_selfInfo.toString()));
		m_requestValues.add(new BasicNameValuePair("gcm_id", m_gcmId));
		return sendPostWithResponse();
	}

}
